package com.usefullc.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.demo.domain.ApplyDayOff;
import com.usefullc.demo.mapper.ApplyDayOffMapper;
import com.usefullc.demo.query.ApplyDayOffQuery;
import com.usefullc.demo.vo.ApplyDayOffVo;
import com.usefullc.system.entity.Pager;
import com.usefullc.system.service.AbstractBizService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 请假条服务类
 * @author: 星空
 * @date: 2022-07-27
 */
@Service
public class ApplyDayOffService extends AbstractBizService<ApplyDayOffMapper, ApplyDayOff, ApplyDayOffQuery> {


    @Override
    protected QueryWrapper<ApplyDayOff> getQueryWrapper(ApplyDayOffQuery query) {
        QueryWrapper<ApplyDayOff> queryWrapper = super.getQueryWrapper(query);
        return queryWrapper;
    }

    public Pager<ApplyDayOffVo> findVoByPage(ApplyDayOffQuery query){
        Pager<ApplyDayOff> page = this.findByPage(query);
        Pager<ApplyDayOffVo> newPage = new Pager<>(page);
        List<ApplyDayOff> dataList = page.getDataList();
        List<ApplyDayOffVo> newDataList = new ArrayList<>();
        newPage.setDataList(newDataList);
        for (ApplyDayOff applyDayOff : dataList) {
            ApplyDayOffVo applyDayOffVo = BeanUtils.beanCopy(applyDayOff, ApplyDayOffVo.class);
            newDataList.add(applyDayOffVo);
        }
        return newPage;
    }


}
